home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / ASSEMBLE / 0419.ZIP / XASM.DOC < prev    next >
Text File  |  1986-03-05  |  10KB  |  303 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.                      X A S M
  20.  
  21.  
  22.                   Revision 1.04
  23.  
  24.  
  25.                A macro configured cross assembler
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.         Copyright 1986 by Stuart Venters  ALL RIGHTS RESERVED.
  33.                   804 Watts Drive.
  34.                   Huntsville, Alabama  35801
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.     THIS SOFTWARE MAY NOT BE USED FOR PROFIT WITHOUT PRIOR WRITTEN
  44.     AUTHORIZATION FROM THE AUTHOR.    The price is $50 and includes
  45.     the latest version release disk and your choice of target machine
  46.     definition file.
  47.  
  48.  
  49.  
  50.  
  51.               History and available targets
  52.  
  53.      XASM is a cross assembler written for single chip computers.  It was not
  54.      written for a specific target machine.  It contains no built in machine
  55.      opcodes like JMP or LOAD.    Instead these are provided by a macro definition
  56.      file for the particular target machine.
  57.  
  58.      XASM is a personal tool which I think may be of general interest.    I wrote
  59.      this assembler after working on several single chip projects with available
  60.      cross assemblers.    This assembler eliminates problems I had with those
  61.      assemblers in areas of cost, speed, error checking, listing format, macro
  62.      implementation, and portability.  It is 4 times faster than the last
  63.      assembler I bought or about 1500 LPM on a PC-AT.  The listing is clean
  64.      showing all of the code bytes and none of the internal macro expansions.
  65.  
  66.      XASM was written in C under CPM80.  It currently runs on MS-DOS. The port
  67.      from CPM to MS-DOS took about two hours.  This speaks well of both C and
  68.      the portability of XASM to other machines.
  69.  
  70.      Plans are to enhance XASM in two directions:  adding a relocating loader
  71.      and creating a microcode assembler for custom projects.  I have made every
  72.      effort to ensure that XASM is a reliable tool.  However, if you find a bug
  73.      or are interested in the enhancements please drop me a note.
  74.  
  75.      XASM can be configured for a variety of targets.  The current list of
  76.      macro files available for XASM is as follows:
  77.  
  78.        1102MACS       (Requires object code scrambler program.)
  79.                Seiko 1102 1112
  80.                SMC 1102
  81.  
  82.        1650MACS       General Instrument PIC-1650 series
  83.  
  84.        6301MACS       Hitachi 6301 6303 63701 6801 6803
  85.                Motorola 6800 6801 6803
  86.  
  87.        6805MACS       Hitachi 6305 6805
  88.                Motorola 6805 68705
  89.  
  90.        8048MACS       INTEL 8048 8041 series
  91.  
  92.        Z8MACS       ZILOG Z8 family
  93.  
  94.      It is my intention to extend this list if there is demand.  To this end
  95.      I will construct the required macro files for other targets as they are
  96.      ordered.
  97.  
  98.  
  99.                 Operation
  100.  
  101.      The assembler is invoked by a command line as follows:
  102.  
  103.     XASM {debug} {filenames} mainfile
  104.  
  105.         Files are read in order from left to right.
  106.         Filenames have ".ASM" appended to them.
  107.         Mainfile.ASM is the last source file.
  108.         Mainfile.LST is the list file.
  109.         Mainfile.HEX is the object file in INTEL hex format.
  110.  
  111.         Example:
  112.         XASM 6805MACS UTIL TEST
  113.             Reads the macro definitions from 6805MACS.ASM
  114.             Reads the utilities file UTIL.ASM
  115.             Reads the test file TEST.ASM
  116.             Writes the object file TEST.HEX
  117.             Writes the listing file TEST.LST
  118.  
  119.         Debug sets the internal debug level from 0 to 9.
  120.            -d1 is useful for watching assembler progress.
  121.            -d4 is useful for debugging macro definitions.
  122.  
  123.      The source file is a text file of source lines.  A source line consists of
  124.      a possible label field, an opcode field, and possibly some operand fields
  125.      separated by commas.  The label field, if present, starts in column 1 and
  126.      may end with a colon.  The opcode field is a single legal variable name
  127.      surrounded on both sides with spaces or tabs.
  128.  
  129.      A real source file follows:
  130.  
  131.  
  132.  
  133. ;define a macro SUM which puts out 1 byte which is the sum or it's arguments
  134. sum      macro
  135.        db      $1+($2)
  136.       endm
  137.  
  138. a      equ      16
  139. b:      set      7      ;
  140.  
  141. ;now use the macro
  142. LABEL:      SUM      a,b      ;set LABEL equal to current pc,
  143.               ; calls macro SUM with $1="A" and $2="B"
  144. ;
  145. b      set      8      ;
  146. ;
  147. label      sum      A,b      ;same, colon and case are not significant
  148.       sum      a,b      ;same, except no label (leading space is delimiter)
  149.  
  150.  
  151.  
  152.                 Assembler built in functions
  153.  
  154.  
  155.     SET  sets the label to the left of the SET to the expression value
  156.     to the right.  Can be done more than once in a pass.  Value is not
  157.     recalculated in pass 2 but is saved from pass 1.
  158.  
  159.     EQU  sets the label to the left of the EQU to the expression value
  160.     to the right.  Label can not have a previous value. Value is not
  161.     recalculated in pass 2 but is saved from pass 1.
  162.  
  163.     ORG  sets the program counter to the value of the expression to the
  164.     right of the ORG.   Value is not recalculated in pass 2 but is saved
  165.     from pass 1.
  166.  
  167.     DB     outputs a byte or series of bytes according to the expression(s) to
  168.     the right of the DB. Legal byte values are from -128 to 255.
  169.  
  170.     DW     outputs a word or series of bytes according to the
  171.     expression(s) to the right of the DW.
  172.  
  173.     PACKING sets the output mode for DW.  PACKING 0 sets MSB first and is the
  174.     default.  PACKING 1 sets LSB FIRST.  PACKING 2 sets word mode.
  175.  
  176.     ERROR marks the current line as being in error.  The argument is a string
  177.     with the error code.
  178.  
  179.     IFERR has two arguments.  The second is evaluated and if non-zero
  180.     an error is caused using the first argument as the error value.
  181.     The evaluation occurs in both pass 1 and 2.  If the expression is
  182.     undefined, no error occurs.
  183.  
  184.     IF     tests the expression to the right of the IF.  If the expression is
  185.     non-zero, the if part is executed.  If the expression is zero or
  186.     undefined, the else part is executed.  The expression is not
  187.     recalculated in pass 2 but is saved from pass 1.  Hence if's always
  188.     execute the same way in pass 1 and 2.
  189.  
  190.     ELSE separates the true part from the false part of an IF sequence.  Is
  191.     optional.
  192.  
  193.     ENDIF terminates an IF sequence.  Is not optional.
  194.  
  195.     TITLE sets the current title string to the string to the right of TITLE.
  196.  
  197.     PAGE causes printing to start on a new page
  198.  
  199.     END  causes assembly to stop.  May be inside an IF statement.
  200.  
  201.     MACRO causes all lines following until an ENDM to be stored as a macro
  202.     definition.  The macro name is the label to the left of MACRO.
  203.  
  204.     ENDM  terminates a macro definition.
  205.  
  206.     INCLUDE causes the file named in the quoted string to the right of INCLUDE
  207.     to be included in the source stream.  Nesting is permitted.
  208.  
  209.  
  210.  
  211.                 Expressions
  212.     Expressions are evaluated from left to right with no hierarchy but
  213.     with parentheses. There are two types of operations.  These are
  214.     numeric and string. All operations are dyadic.    They take a left
  215.     and right value or expression in parens and put out an expression
  216.     value.
  217.  
  218.         The numeric operations work on numeric values.    If they
  219.         are given a string, they will use the character code of
  220.         the first string element as the numeric value.    Arithmetic
  221.         is 16 bit unsigned. The list of operations is as follows:
  222.  
  223.             +   addition
  224.             -   subtraction
  225.             *   multiply
  226.             /   divide
  227.             &   bitwise and
  228.             |   bitwise or
  229.             <   relation less than. (0 if false, 1 if true)
  230.             >   relation greater than. (0 if false, 1 if true)
  231.             =   relation equal to. (0 if false, 1 if true)
  232.             !   relation not equal to. (0 if false, 1 if true)
  233.  
  234.  
  235.         The string operations are included to make programming target
  236.         machine opcode macros easier.  They operate on two strings.
  237.         The operations are as follows:
  238.  
  239.             =  Returns 1 if the strings are equal. 0 otherwise.
  240.  
  241.             !  Returns 0 if the strings are equal. 1 otherwise.
  242.  
  243.             ?  Returns 1 if the characters in the first string
  244.                  match the first characters in the second string.
  245.                  Else returns 0.
  246.  
  247.             ^  Called with a string on the left and an expression
  248.                  on the right.  First removes the leading characters
  249.                  in the expression which match the string. Next
  250.                  evaluates the rest of the expression and returns
  251.                  result.
  252.  
  253.  
  254.                 Values
  255.      Values are the simplest form of an expression.  There are three types
  256.      of values.  These are constants, variables, and pseudo constants.
  257.  
  258.     String constants are formed by a string of characters enclosed in
  259.     double quotes.    A backslash is an escape character in a string.  A
  260.     double quote can be entered by preceeding it with a backslash.    Watch
  261.     backslashes in filenames of INCLUDE statements.  (DOS takes forward
  262.     slashes just fine.)
  263.  
  264.     Numeric constants always begin with "0" thru "9".  Examples of
  265.     the possible numeric constants are as follows:
  266.  
  267.         123    a simple base 10 number
  268.         123d    the same base 10 number
  269.         10X123    the same base 10 number
  270.  
  271.         16XABC    the base 16 number ABC
  272.         ABCh    the same base 16 number
  273.         0XABC    the same base 16 number (base 0 --> base 16)
  274.  
  275.         777q    the base 8 number 777
  276.         8x777    same
  277.  
  278.         101b    the base 2 number 101
  279.         2x101    same
  280.  
  281.         36x10Q    the base 36 number 10Q
  282.  
  283.     Variables always begin with "A" thru "Z".  The following characters
  284.     may be "A"-"Z", "0"-"9", or  "_".  Examples of legal variables are:
  285.  
  286.         A
  287.         A923
  288.         a923   (The same as case does not count.)
  289.         FIRST_ONE
  290.         FIRST_ONE_1 (Symbol size is not limited.)
  291.  
  292.     Pseudo constants always begin with "$".
  293.  
  294.         $ means the program counter value at the beginning of the
  295.             current source file line. (Not macro line.)
  296.  
  297.         $1 means the first macro argument
  298.          .
  299.          .
  300.         $9 means the ninth macro argument
  301.  
  302.      Values may be preceeded by a minus sign.
  303.